#!/usr/bin/env python
# -*- coding: utf8 -*-
import json
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest

def GetToken():
    client = AcsClient(
       "LTAI4FhtuzrvG5JAzKwqiin6",
       "Fq0Rw1K26YTyKXTJIx458ZhYXQaq83",
       "cn-shanghai"
    );
    request = CommonRequest()
    request.set_method('POST')
    request.set_domain('nls-meta.cn-shanghai.aliyuncs.com')
    request.set_version('2019-02-28')
    request.set_action_name('CreateToken')
    response = client.do_action_with_exception(request)
    res = json.loads(response)
    token = res['Token']['Id']
    return token

if __name__ == "__main__":
    GetToken()
